<template>
  <div>
    <div>
      <MusicBack title="推荐歌单" :arrow="true" />
      <MusicLaoding v-if="laoding" />
      <van-row v-else type="flex" class="box">
        <van-col
          span="6"
          v-for="item in songs"
          :key="item.id"
          @click="toDetail(item.id)"
        >
          <van-image
            radius=".3125rem"
            width="80"
            height="80"
            lazy-load
            :src="item.picUrl + '?param=200y200'"
          >
            <span class="playCount">
              <span class="iconfont">&#xe628;</span>
              <span v-if="Math.floor(item.playCount) >= 100000000">{{ Math.floor(item.playCount / 100000000) }} 亿</span>
              <span v-else>{{ Math.floor(item.playCount / 10000) }} 万</span>
            </span>
          </van-image>
          <span class="van-multi-ellipsis--l2">{{ item.name }}</span>
        </van-col>
      </van-row>
    </div>
  </div>
</template>

<script>
import { GetpersonalizedAPI } from "@/api/api.js";
import MusicBack from "@/components/common/back.vue";
import MusicLaoding from "@/components/common/laoding.vue";
export default {
  name: "MusicSongsListMore",
  components: {
    MusicBack,
    MusicLaoding,
  },
  data() {
    return {
      songs: [],
      laoding: true,
    };
  },

  mounted() {
    this.onLoad();
  },

  methods: {
    onLoad() {
      // 异步更新数据
      GetpersonalizedAPI({ limit: 200 }).then((res) => {
        if (res.status == 200) {
          this.songs = res.data.result;
          this.laoding = false;
        }
      });
    },
    toDetail(id) {
      this.$router.push({
        path: "/MusicDetail",
        query: { id },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.box {
  .van-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.3125rem;
    font-size: 0.75rem;
    .van-image {
      position: relative;
      .playCount {
        position: absolute;
        top: .1875rem;
        right: .1875rem;
        color: #fff;
        background: rgba(0, 0, 0, 0.15);
        border-radius: 3.125rem;
        padding: 0rem .2188rem;
        .iconfont {
          font-size: .75rem;
        }
      }
    }
  }
}
</style>